from typing import List
import logging
import collections
import heapq

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s",
    datefmt="%Y-%m-%d %H:%M:%S",
)
# 好吧，没有任何思路


class Solution:
    def isPossible(self, nums: List[int]) -> bool:
        mp = collections.defaultdict(list)
        for x in nums:
            if queue := mp.get(x - 1):
                print("...", mp)
                prevLength = heapq.heappop(queue)
                heapq.heappush(mp[x], prevLength + 1)
            else:
                heapq.heappush(mp[x], 1)
                print("----", mp)
            print(mp)

        return not any(queue and queue[0] < 3 for queue in mp.values())


if __name__ == "__main__":
    res = Solution().isPossible([1, 2, 3, 3, 4, 5])
    # res = Solution().isPossible([])
    print(res)

